package cn.changein.framework.admin.setting.thirdInterface;

import cn.changein.framework.base.controller.BaseController;
import cn.changein.framework.base.pojo.page.PageInfo;
import cn.changein.framework.kernel.model.response.ResponseData;
import cn.changein.framework.model.setting.thirdInterfaceConfig.entity.ThirdInterfaceConfig;
import cn.changein.framework.model.setting.thirdInterfaceConfig.model.params.ThirdInterfaceConfigParam;
import cn.changein.framework.service.setting.thirdInterfaceConfig.ThirdInterfaceConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 对接第三方接口的配置控制器
 *

 * @Date 2021-01-21 20:27:45
 * @Copyright: companyName
 * @Version 1.0
 * @Since JDK1.8
 */
@Controller
@RequestMapping("/thirdInterfaceConfig")
public class ThirdInterfaceConfigController extends BaseController {

    private String PREFIX = "/modular/setting/thirdInterfaceConfig";

    @Autowired
    private ThirdInterfaceConfigService thirdInterfaceConfigService;

    /**
     * 跳转到主页面
     *

     * @Date 2021-01-21
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/thirdInterfaceConfig.html";
    }

    /**
     * 新增页面
     *

     * @Date 2021-01-21
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/thirdInterfaceConfig_add.html";
    }

    /**
     * 编辑页面
     *

     * @Date 2021-01-21
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/thirdInterfaceConfig_edit.html";
    }

    /**
     * 新增接口
     *

     * @Date 2021-01-21
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(ThirdInterfaceConfigParam thirdInterfaceConfigParam) {
        this.thirdInterfaceConfigService.add(thirdInterfaceConfigParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *

     * @Date 2021-01-21
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(ThirdInterfaceConfigParam thirdInterfaceConfigParam) {
        this.thirdInterfaceConfigService.update(thirdInterfaceConfigParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *

     * @Date 2021-01-21
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(ThirdInterfaceConfigParam thirdInterfaceConfigParam) {
        this.thirdInterfaceConfigService.delete(thirdInterfaceConfigParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *

     * @Date 2021-01-21
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(ThirdInterfaceConfigParam thirdInterfaceConfigParam) {
        ThirdInterfaceConfig detail = this.thirdInterfaceConfigService.getById(thirdInterfaceConfigParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *

     * @Date 2021-01-21
     */
    @ResponseBody
    @RequestMapping("/list")
    public PageInfo list(ThirdInterfaceConfigParam thirdInterfaceConfigParam) {
        return this.thirdInterfaceConfigService.findPageBySpec(thirdInterfaceConfigParam);
    }

}


